package cn.com.pansky.service;

import java.util.Map;

import cn.com.pansky.action.logs.Log;
import cn.com.pansky.sdk.API;
import net.vsame.url2sql.action.CommonAction;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

/**
 * 银行支付成功，回填业务数据
 * @author Administrator
 *
 */
public class OrderBackWriteService extends CommonAction {

	private Log log = new Log();
	
	/**
	 * 支付成功，回填业务系统数据
	 * @param args
	 */
	public JSONObject orderBackWrite(Map<String, String> map) {
		JSONObject param = new JSONObject();
		param.put("AAA121", "A2002003"); // 缴费标识
		param.put("AAC002", map.get("AAC002")); // 身份证号
		param.put("AAZ065", map.get("bankType")); // 银行ID
		param.put("AAE010", map.get("AAE010")); // 当事人缴费账号
		param.put("AAE074", map.get("AcqSsn")); // 银行缴费流水号
		param.put("AAE022", map.get("TranAmt")); // 缴费金额
		param.put("AAZ288", map.get("TermSsn")); // 社保流水号
		param.put("AAE011", map.get("AAE011")); // 代理人ID
		param.put("AAE010", map.get("AAE010"));//支付银行卡号
		System.out.println(param.toString());
		JSONObject object = API.sendController("paymentController.json", param);
		
		//日志记录end
//		String AF001 = (String) context.getServletSession().getAttribute("AF001");
//		boolean result = log.end(AF001, "true", object);
//		System.out.println("日志：个人版新用户注册："+result);
//		context.getServletSession().removeAttribute("CA001");
//		context.getServletSession().removeAttribute("AF001");
		
		return object;
	}
	
//	public static void main(String[] args) {
////		{"AAE022":"130","AAZ288":"17417315","AAE010":"999999",
////		"AAA121":"A2002003","AAE011":"da278d65-a2e5-48f5-8f40-03ddb5ae457e",
////		"AAZ065":"JH","AAC002":"612429198908280783","AAE074":"J100010105620161018115950490"}
//		
//		OrderBackWriteService os = new OrderBackWriteService();
//		Map<String, String> map = new HashMap<String, String>();
//		map.put("AAE010", "999999"); // 当事人缴费账号
//		map.put("bankType", "JH");
//		map.put("AcqSsn", "J100010105620161018115950490");// 银行缴费流水号
////		map.put("TranAmt", reqMap.get("orderAmount"));// 缴费金额  //TODO 测试写死
//		map.put("TranAmt", "100");// 缴费金额  //TODO 测试写死
//		map.put("TermSsn", "17417315");// 社保流水号
//		map.put("AAC002", "612429198908280783");//身份证号
//		map.put("AAE011", "da278d65-a2e5-48f5-8f40-03ddb5ae457e");//代理人ID
//		os.orderBackWrite(map);
//	}
	public void isInsured() {
		
//		入参：AAA121:QNWAC01
//		  AAC002:身份证数组
//		  queryRegisterVerify
		
		JSONObject param = new JSONObject();
		param.put("AAA121", "QNWAC01"); // 缴费标识
		JSONObject aac002 = new JSONObject();
		aac002.put("AAC002", "610629197912215014");
		
		JSONArray json = new JSONArray();
		json.add(aac002);
		
		param.put("AAC002", json); // 
//		param.put("AAC002", "612429198908280783"); // 
		System.out.println(param.toString());
		JSONObject object = API.sendController("queryRegisterVerify.json", param);
		System.out.println("业务系统数据返回结果："+object);
		
		
		param.put("AAA121", "QNWAC70"); // 缴费标识
		object = API.sendController("queryBenefitVerify.json", param);
		System.out.println("业务系统数据返回结果："+object);
		
		param.put("AAA121", "QNWIC76"); // 缴费标识
		object = API.sendController("queryTransferVerify.json", param);
		System.out.println("业务系统数据返回结果："+object);
	}
	
	public static void main(String[] args) {
		OrderBackWriteService os = new OrderBackWriteService();
		os.isInsured();
	}
}
